package com.example.leepong.Interaction;

import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;

import com.example.leepong.Game.Shapes.Coordinates;
import com.example.leepong.GameSurface;


public class GestureHandler extends GestureDetector.SimpleOnGestureListener {
    private GameSurface _surface;

    public GestureHandler(GameSurface surface) {
        this._surface = surface;
    }

    @Override
    public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
        //  Log.D("-------------", "OnScroll X:" + e1.GetX(0) + " Y:" + e1.Y + " dX:" + distanceX + " dY:" + distanceY);
        this._surface.Engine.TouchScroll(new Coordinates(e2.getX(), e2.getY()), new Coordinates(e2.getX() + distanceX, e2.getY() + distanceY));

      //  Log.d("-------------", "hist:" + e2.getHistorySize());
        return true;
    }

    @Override
    public boolean onSingleTapUp(MotionEvent e) {
        return true;
    }

    @Override
    public boolean onDown(MotionEvent e) {
        this._surface.Engine.TouchSingleTap(new Coordinates(e.getX(), e.getY()));
        //  Log.D("-------------", "" + e.GetPointerCount());
        return true;
    }

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        // Log.D("-------------", "x:" + e2.X + " velx:" + velocityX + " vely:" + velocityY);
        return true;
    }
}
